/**
 * $Revision: 1.0 $
 * $Author: Geln Yang $
 * $Date: Jul 6, 2009 9:39:14 AM $
 *
 * Author: Eric Yang
 * Date  : Jul 6, 2009 9:39:14 AM
 *
 */
package c4j.regex;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Eric Yang
 * @version 1.0
 */
public class TestRegex {
	public static void main(String[] args) {
		test3();

	}

	public static void test1() {
		String s = "\\d*[1-9]+\\d*";
		System.out.println("0000000".matches(s));
		System.out.println("0000100".matches(s));

	}

	public static void test2() {
		String s = "(?:(?!EOF).){3}";
		System.out.println("EOF".matches(s));
		System.out.println("EOE".matches(s));
		System.out.println("dddd".matches(s));
		System.out.println("d".matches(s));

	}

	public static void test3() {
		System.out.println("a1=344".matches("[^=]+=.*"));

		String s = "AAA\r\n";
		s += "a1=1231\r\n";
		s += "a2=55\r\n";
		s += "a3=\r\n";
		s += "a4=  \r\n";
		Pattern pattern = Pattern.compile("\\S+=[ ]*\r\n");
		Matcher matcher = pattern.matcher(s);
		if (matcher.find()) {
			System.out.println(matcher.group(0));
			matcher.find();
			System.out.println(matcher.group(0));
			/**
			 * Why the value of matcher.groupCount() is zero ???
			 * */
			for (int i = 0; i <matcher.groupCount() ; i++) {
				System.out.println(matcher.group(i));
			}
		}
	}
}
